
package com.scs.application.modules.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scs.application.core.service.BaseServiceImpl;
import com.scs.application.modules.base.entity.MaterialInquiryItem;
import com.scs.application.modules.base.mapper.MaterialInquiryItemMapper;
import com.scs.application.modules.base.request.MaterialInquiryItemQueryRequest;
import com.scs.application.modules.base.service.MaterialInquiryItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 耗材询价单明细 service 实现
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class MaterialInquiryItemServiceImpl extends BaseServiceImpl<MaterialInquiryItemMapper, MaterialInquiryItem> implements MaterialInquiryItemService {

    @Override
    public List<MaterialInquiryItem> list(MaterialInquiryItemQueryRequest request) {
        List<MaterialInquiryItem> list = this.list(getQueryWrapper(request));
        return list;
    }

    @Override
    public IPage<MaterialInquiryItem> page(MaterialInquiryItemQueryRequest request) {
        IPage page = this.page(request.getPage(), getQueryWrapper(request));
        return page;
    }

    private QueryWrapper<MaterialInquiryItem> getQueryWrapper(MaterialInquiryItemQueryRequest request) {
        return Wrappers.<MaterialInquiryItem>query()
                .orderByDesc("gmt_modified");
    }
}
